# coding=utf-8
import time

import allure
from selenium import webdriver
from selenium.webdriver.common.by import By

from homework_web_po.base_page.base_page import BasePage


class AddressBookPage(BasePage):

    _ADD_BTN = By.XPATH, "(//a[text()='添加成员'])[2]"
    _GET_MENGER_INFO = By.XPATH, "//*[@id='member_list']/tr/td[@title][1]"      # 获取成员信息


    @allure.step("进入添加成员页面")
    def add_menger(self):
        from homework_web_po.po.add_menger_page import AddMengerPage
        print("进入添加成员页面")
        time.sleep(3)
        self.click(*self._ADD_BTN)
        return  AddMengerPage(self.driver)


    @allure.step("获取成员信息")
    def get_memger_info(self):
        time.sleep(2)
        elements = self.find_eles(*self._GET_MENGER_INFO)
        name_list = []
        for ele in elements:
            name_list.append(ele.get_attribute("title"))
        print(f"成员信息：{name_list}")
        return name_list

